package com.java110.mall.cart.api;

import com.java110.mall.cart.bmo.report.IMallReport;
import com.java110.dto.mallReport.MallReportDto;
import com.java110.dto.mallReport.SellingCostDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 报表api
 */
@RestController
@RequestMapping(value = "/mallReport")
public class MallReportApi {

    @Autowired
    private IMallReport getInStockImpl;

    /**
     * 进货统计
     *
     * @return
     * @serviceCode /mallReport/getInStockInfo
     * @path /app/mallReport/getInStockInfo
     */
    @RequestMapping(value = "/getInStockInfo", method = RequestMethod.GET)
    public ResponseEntity<String> getInStockInfo(@RequestParam(value = "shopId", required = false) String shopId,
                                                 @RequestParam(value = "beginTime", required = false) String beginTime,
                                                 @RequestParam(value = "endTime", required = false) String endTime,
                                                 @RequestParam(value = "prodNameLike", required = false) String prodNameLike,
                                                 @RequestParam(value = "page") int page,
                                                 @RequestParam(value = "row") int row) {
        MallReportDto mallReportDto = new MallReportDto();
        mallReportDto.setShopId(shopId);
        mallReportDto.setBeginTime(beginTime);
        mallReportDto.setEndTime(endTime);
        mallReportDto.setProdNameLike(prodNameLike);
        mallReportDto.setPage(page);
        mallReportDto.setRow(row);
        return getInStockImpl.getInStockInfo(mallReportDto);
    }

    /**
     * 销售明细
     *
     * @return
     * @serviceCode /mallReport/getSalesInfo
     * @path /app/mallReport/getSalesInfo
     */
    @RequestMapping(value = "/getSalesInfo", method = RequestMethod.GET)
    public ResponseEntity<String> getSalesInfo(@RequestParam(value = "shopId", required = false) String shopId,
                                               @RequestParam(value = "beginTime", required = false) String beginTime,
                                               @RequestParam(value = "endTime", required = false) String endTime,
                                               @RequestParam(value = "prodNameLike", required = false) String prodNameLike,
                                               @RequestParam(value = "page") int page,
                                               @RequestParam(value = "row") int row) {
        MallReportDto mallReportDto = new MallReportDto();
        mallReportDto.setShopId(shopId);
        mallReportDto.setBeginTime(beginTime);
        mallReportDto.setEndTime(endTime);
        mallReportDto.setProdNameLike(prodNameLike);
        mallReportDto.setPage(page);
        mallReportDto.setRow(row);
        return getInStockImpl.getSalesInfo(mallReportDto);
    }


    /**
     * 进货明细
     *
     * @return
     * @serviceCode /mallReport/getInoutInfo
     * @path /app/mallReport/getInoutInfo
     */
    @RequestMapping(value = "/getInoutInfo", method = RequestMethod.GET)
    public ResponseEntity<String> getInoutInfo(@RequestParam(value = "shopId", required = false) String shopId,
                                               @RequestParam(value = "beginTime", required = false) String beginTime,
                                               @RequestParam(value = "endTime", required = false) String endTime,
                                               @RequestParam(value = "prodNameLike", required = false) String prodNameLike,
                                               @RequestParam(value = "page") int page,
                                               @RequestParam(value = "row") int row) {
        MallReportDto mallReportDto = new MallReportDto();
        mallReportDto.setShopId(shopId);
        mallReportDto.setBeginTime(beginTime);
        mallReportDto.setEndTime(endTime);
        mallReportDto.setProdNameLike(prodNameLike);
        mallReportDto.setPage(page);
        mallReportDto.setRow(row);
        return getInStockImpl.getInoutInfo(mallReportDto);
    }


    /**
     * 微信删除消息模板
     *
     * @return
     * @serviceCode /mallReport/getSalesRankingInfo
     * @path /app/mallReport/getSalesRankingInfo
     */
    @RequestMapping(value = "/getSalesRankingInfo", method = RequestMethod.GET)
    public ResponseEntity<String> getSalesRankingInfo(@RequestParam(value = "beginTime", required = false) String beginTime,
                                                      @RequestParam(value = "endTime", required = false) String endTime,
                                                      @RequestParam(value = "shopId", required = false) String shopId,
                                                      @RequestParam(value = "prodNameLike", required = false) String prodNameLike,
                                                      @RequestParam(value = "page") int page,
                                                      @RequestParam(value = "row") int row) {
        MallReportDto mallReportDto = new MallReportDto();
        mallReportDto.setProdNameLike(prodNameLike);
        mallReportDto.setShopId(shopId);
        mallReportDto.setBeginTime(beginTime);
        mallReportDto.setEndTime(endTime);
        mallReportDto.setPage(page);
        mallReportDto.setRow(row);
        return getInStockImpl.getSalesRankingInfo(mallReportDto);
    }

    /**
     * 销售成本
     *
     * @return
     * @serviceCode /mallReport/sellingCost
     * @path /app/mallReport/sellingCost
     */
    @RequestMapping(value = "/sellingCost", method = RequestMethod.GET)
    public ResponseEntity<String> getSellingCost(@RequestParam(value = "beginTime", required = false) String beginTime,
                                                 @RequestParam(value = "endTime", required = false) String endTime,
                                                 @RequestParam(value = "shopId", required = false) String shopId,
                                                 @RequestParam(value = "page") int page,
                                                 @RequestParam(value = "row") int row) {
        SellingCostDto sellingCostDto = new SellingCostDto();
        sellingCostDto.setShopId(shopId);
        sellingCostDto.setBeginTime(beginTime);
        sellingCostDto.setEndTime(endTime);
        sellingCostDto.setPage(page);
        sellingCostDto.setRow(row);
        return getInStockImpl.getSellingCost(sellingCostDto);
    }

    /**
     * 销售成本明细
     *
     * @return
     * @serviceCode /mallReport/sellingCostDetail
     * @path /app/mallReport/sellingCostDetail
     */
    @RequestMapping(value = "/sellingCostDetail", method = RequestMethod.GET)
    public ResponseEntity<String> getSellingCostDetail(@RequestParam(value = "beginTime", required = false) String beginTime,
                                                       @RequestParam(value = "endTime", required = false) String endTime,
                                                       @RequestParam(value = "shopId", required = false) String shopId,
                                                       @RequestParam(value = "prodNameLike", required = false) String prodNameLike,
                                                       @RequestParam(value = "page") int page,
                                                       @RequestParam(value = "row") int row) {
        SellingCostDto sellingCostDto = new SellingCostDto();
        sellingCostDto.setShopId(shopId);
        sellingCostDto.setBeginTime(beginTime);
        sellingCostDto.setProdNameLike(prodNameLike);
        sellingCostDto.setEndTime(endTime);
        sellingCostDto.setPage(page);
        sellingCostDto.setRow(row);
        return getInStockImpl.getSellingCostDetail(sellingCostDto);
    }
}
